package com.hkts.reportform.utils;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.StringUtils;


public class CustomPage {
    @Getter@Setter
    private Integer pageNumber;
    @Getter@Setter
    private Integer pageSize;
    @Getter
    private Integer totalRows;
    @Getter@Setter
    private Integer totalPages;
    @Getter@Setter
    private Object resultData;
    @Getter
    private String order="ASC";

   public void setOrder(String order) {
        if(StringUtils.isBlank(order)){
            this.order = "ASC";
        }else if(order.equals("1")){
            this.order =  "ASC";
        }else if(order.equals("0")){
            this.order = "DESC";
        }else {
            this.order = order;
        }
    }

    public void setTotalRows(Integer totalRows) {
        if(totalRows%pageSize==0){
            this.totalPages= totalRows/pageSize;
        }else{
            this.totalPages= totalRows/pageSize+1;
        }
        this.totalRows = totalRows;
    }
}
